using System.Collections.Generic;
using DynamicChart.Model;
using DynamicChart.Service;
using Microsoft.AspNetCore.Mvc;

namespace DynamicChart.Controllers;

[ApiController]
[Route("[controller]/[action]")]
public class ActuatorController : ControllerBase
{
    private readonly ActuatorService _actuatorService;

    public ActuatorController(ActuatorService actuatorService)
    {
        _actuatorService = actuatorService;
    }
    
    [HttpGet]
    public List<ActuatorModel> LoadActuatorModel(string name = "")
    {
        return _actuatorService.LoadActuatorModel(name);
    }
    
    [HttpGet]
    public ActuatorModel GetById(int id)
    {
        return _actuatorService.GetById(id);
    }
    
    [HttpPost]
    public string CreateSQL([FromBody] IDictionary<string, object> param)
    {
        return _actuatorService.CreateSQL(param);
    }
    
    
    [HttpPost]
    public IDictionary<string, object> DoActuator([FromBody] IDictionary<string, object> param)
    {
        return _actuatorService.DoActuator(param);
    }
    
    [HttpGet]
    public IDictionary<string, object> LoadTableStructure(string name = "")
    {
        return _actuatorService.LoadTableStructure(name);
    }
    
    [HttpPost]
    public Boolean SaveActuator([FromBody] ActuatorModel actuatorModel)
    {
        return _actuatorService.SaveActuator(actuatorModel);
    }
}